package com.shuizhu.util;

import org.apache.poi.ss.usermodel.CellStyle;
import org.apache.poi.ss.usermodel.Row;

import com.alibaba.excel.write.style.row.AbstractRowHeightStyleStrategy;

/**
 * excel表格的行高设置及样式
 *
 * @author 睡竹
 */
public class CustomRowHeightStyleStrategy extends AbstractRowHeightStyleStrategy {

    /**
     * 设置需要隐藏的行号
     */
    Integer rowNum;

    public CustomRowHeightStyleStrategy(int rowNum){
        this.rowNum = rowNum;
    }

    /**
     * 设置表头的行高
     */
    @Override
    protected void setHeadColumnHeight(Row row, int relativeRowIndex) {
        //设置表头行高为18
        row.setHeightInPoints(18);
    }

    /**
     * 设置内容的行高 relativeRowIndex为行数，索引从0开始
     */
    @Override
    protected void setContentColumnHeight(Row row, int relativeRowIndex) {
        System.out.println(relativeRowIndex);
        if (relativeRowIndex + 1 == rowNum) {
            //设置行隐藏
            row.setHeightInPoints((0));
        }
    }
}
